package br.com.absolutech.study.chapter5.p213ex4;

/**
 * 
 * To test this class, please declare some "Program arguments"
 * 
 * @author Romulo
 *
 */
public class MyException {

    public static void main(String[] args) {

	for (int i = 0; i < args.length; i++) {
	    if (args[i] == null) {
		System.out.println("Parametro esperado");
		System.exit(1);
	    }

	    try {
		checkFood(args[i]);
	    } catch (BadFoodException e) {
		System.err.println("Bad Food Exception with: " + args[i]);
		//	    e.printStackTrace();
	    }
	}

    }

    static void checkFood(String food) throws BadFoodException {
	if (food.equalsIgnoreCase("ostra")) {
	    throw new BadFoodException();
	}
	System.out.println(food + " is acceptable");
    }
}
